package cloud.shyidong.tenant.commerce.service;

import cloud.shyidong.commerce.dao.CommerceGoodsDao;
import cloud.shyidong.commerce.dao.CommerceIndexDao;
import cloud.shyidong.commerce.entity.CommerceGoodsEntity;
import cloud.shyidong.commerce.entity.CommerceIndexEntity;
import cloud.shyidong.commerce.request.CommerceIndexInsertRequest;
import cloud.shyidong.commerce.request.CommerceIndexPageRequest;
import cloud.shyidong.commerce.request.CommerceIndexUpdateRequest;
import cloud.shyidong.core.request.LongIdRequest;
import cloud.shyidong.core.service.AbstractTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 业务处理
 * </p>
 *
 * @author syd
 * @since 2023-09-18 15:34:23
 */
@Service
public class CommerceIndexService extends AbstractTenantService<CommerceIndexDao, CommerceIndexEntity, LongIdRequest, CommerceIndexInsertRequest, CommerceIndexUpdateRequest, CommerceIndexPageRequest> {
    
    private CommerceGoodsDao commerceGoodsDao;
    
    @Autowired
    public void setCommerceGoodsDao(CommerceGoodsDao commerceGoodsDao) {
        this.commerceGoodsDao = commerceGoodsDao;
    }
    
    @Override
    public Map<String, Object> view(LongIdRequest idRequest) {
        Map<String, Object> result = super.view(idRequest);
        Long goodsId = (Long) result.get("goodsId");
        CommerceGoodsEntity commerceGoodsEntity = commerceGoodsDao.selectById(goodsId);
        result.put("goodsName", commerceGoodsEntity.getName());
        return result;
    }
    
}
